import axios from "axios";

export default {
	namespaced:true,
	state:{
		token:localStorage.getItem("token"),
		adminInfo:{}
	},
	mutations:{
		SET_TOKEN(state,token){
			state.token = token;
			localStorage.setItem("token",token);
		},
		SET_INFO(state,value){
			state.adminInfo = value;
		}
	},
	getters:{
		myAdmin(){
			return 200;
		}
	},
	actions:{
		async login({commit},payload){
			const {data} = await axios.post("/api/admin/login",payload);
			commit("admin/SET_TOKEN",data.token);
		},
		async getAdminInfo({state,commit}){
			// const {data} = await axios.post("/api/adminList/info",{
			// 	headers:{
			// 		token:state.token
			// 	}
			// });
			// commit("admin/SET_INFO",data.info);
		}
	}
};